﻿using HCMS.Upload.Util;
using Microsoft.AspNetCore.Mvc;

namespace HCMS.Upload.Controllers
{
    /// <summary>
    /// 上传控制器
    /// </summary>
    [Route("api/{Controller}/{Action}")]
    public class UploadController : Controller
    {
        public IWebHostEnvironment webHostEnvironment;

        public UploadController(IWebHostEnvironment webHostEnvironment)
        {
            this.webHostEnvironment = webHostEnvironment;
        }

        /// <summary>
        /// 图片上传
        /// </summary>
        /// <param name="files">待上传的图片列表</param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult Imgs(List<IFormFile> files)
        {
            var result = new UploadUtil().UploadHandle(files, webHostEnvironment.WebRootPath, UploadFileType.Imgs);
            return Json(result);
        }
    }
}
